﻿<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-3.1.xsd
                        http://www.springframework.org/schema/aop
                        http://www.springframework.org/schema/aop/spring-aop.xsd
                        http://www.springframework.org/schema/mvc
                        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
	<!-- 自动扫描该包 -->
	<context:annotation-config />
	<context:component-scan base-package="${packageName}.*" />
	<mvc:resources location="/mystatic/" mapping="/mystatic/**" />
    <mvc:resources location="/css/" mapping="/css/**" />
    <mvc:resources location="/fonts/" mapping="/fonts/**" />
    <mvc:resources location="/img/" mapping="/img/**" />
    <mvc:resources location="/js/" mapping="/js/**" />
    <mvc:resources location="/views/" mapping="/views/**" />
    <mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper">
                    <bean class="${packageName}.config.JacksonConfig"/>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
<#if theme == "经典后台Thymleaf版">
	<#if isAuthority>
	<mvc:view-controller path="/cm_sys_user/list" view-name="cmSysUser/list"/>
	<mvc:view-controller path="/cm_sys_menu/list" view-name="cmSysMenu/list"/>
	<mvc:view-controller path="/cm_sys_role/list" view-name="cmSysRole/list"/>
	</#if>
	<#list tableNameList?keys as key>
	<mvc:view-controller path="/${key}/list" view-name="${key}/list"/>
	</#list>
	
	<#if tablesQueryMap??>
	<#list tablesQueryMap?keys as key>
		<#assign methods = tablesQueryMap["${key}"]/>
		<#list methods?keys as methodKey>
	<mvc:view-controller path="/${key}Muti/${methodKey}List" view-name="${key}Muti/${methodKey}List"/>
		</#list>
	</#list>
	</#if>
	<mvc:view-controller path="/home" view-name="home"/>
	<mvc:view-controller path="/welcome" view-name="welcome"/>
	<mvc:view-controller path="/login" view-name="login"/>
</#if>
	<#if ifUseSwagger == "是">
	<bean class="${packageName}.config.SwaggerConfig"/>
    <!-- 配置swagger资源不被拦截 -->
    <mvc:resources location="classpath:/META-INF/resources/" mapping="swagger-ui.html"/>
    <mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"/>
    <mvc:resources location="classpath:/META-INF/resources/" mapping="doc.html"/>
	</#if>

	<mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/login" />
			<mvc:exclude-mapping path="/login/doLogin" />
			<mvc:exclude-mapping path="/register" />
			<mvc:exclude-mapping path="/mystatic/**" />
			<mvc:exclude-mapping path="/druid/**" />
			<#if ifUseSwagger == "是">
			<mvc:exclude-mapping path="/webjars/**"/><!-- swagger静态资源-->
            <mvc:exclude-mapping path="/v2/**"/><!-- swagger静态资源-->
            <mvc:exclude-mapping path="/swagger-ui.html/**"/><!-- swagger静态资源-->
            <mvc:exclude-mapping path="/doc.html/**"/>
            <mvc:exclude-mapping path="/swagger-resources/**"/><!-- swagger静态资源-->
			</#if>
			<bean class="${packageName}.config.MVCInterceptor" />
		</mvc:interceptor>
	</mvc:interceptors>

	<!--避免IE执行AJAX时，返回JSON出现下载文件 -->
	<bean id="mappingJacksonHttpMessageConverter"
		class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
		<property name="supportedMediaTypes">
			<list>
				<value>text/html;charset=UTF-8</value>
				<value>application/json;charset=UTF-8</value>
			</list>
		</property>
	</bean>

	<!-- 引入thymeleaf -->
	<bean id="templateResolver"
		class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">
		<property name="prefix" value="/WEB-INF/" />
		<property name="suffix" value=".html" />
		<property name="templateMode" value="HTML" />
		<property name="cacheable" value="false" />
		<property name="characterEncoding" value="UTF-8" />
	</bean>

	<bean id="templateEngine"
		class="org.thymeleaf.spring4.SpringTemplateEngine">
		<property name="templateResolver" ref="templateResolver" />
	</bean>

	<bean id="viewResolver"
		class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
		<property name="templateEngine" ref="templateEngine" />
		<property name="characterEncoding" value="UTF-8" />
	</bean>

	<!-- 配置文件上传，如果没有使用文件上传可以不用配置，当然如果不配，那么配置文件中也不必引入上传组件包 -->
	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<!-- 默认编码 -->
		<property name="defaultEncoding" value="utf-8" />
		<!-- 文件大小最大值 -->
		<property name="maxUploadSize" value="10485760000" />
		<!-- 内存中的最大值 -->
		<property name="maxInMemorySize" value="40960" />
	</bean>
	<aop:aspectj-autoproxy/>
	<aop:config proxy-target-class="true"/>

</beans>  